package com.hsjk.szwj.module.train.controller.admin;

import com.hsjk.szwj.framework.common.pojo.CommonResult;
import com.hsjk.szwj.module.train.controller.admin.vo.AdminCreatePlatformCourseReqVO;
import com.hsjk.szwj.module.train.controller.admin.vo.AdminDeletePlatformCourseReqVO;
import com.hsjk.szwj.module.train.service.IPlatformCourseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.hsjk.szwj.framework.common.pojo.CommonResult.success;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/11/14 01:14
 **/
@Tag(name = "后台管理端 - 平台课程关联相关接口")
@RestController
@RequestMapping("/train/platform-course-mapping")
@Validated
public class AdminPlatformCourseMappingController {
    @Resource
    private IPlatformCourseService platformCourseService;

    @PostMapping("/create")
    @Operation(summary = "创建平台关联课程")
    @PreAuthorize("@ss.hasPermission('train:platform-course-mapping:create')")
    public CommonResult<Boolean> createPlatformCourse(@RequestBody @Valid AdminCreatePlatformCourseReqVO reqVO) {
        return success(platformCourseService.createPlatformCourse(reqVO));
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除平台关联课程")
    @PreAuthorize("@ss.hasPermission('train:platform-course-mapping:delete')")
    public CommonResult<Boolean> deletePlatformCourse(@RequestBody @Valid AdminDeletePlatformCourseReqVO reqVO) {
        return success(platformCourseService.deletePlatformCourse(reqVO));
    }


}
